home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Merciful 2
/
Merciful - Disc 2.iso
/
software
/
l
/
lightwave3dv3.5a.dms
/
lightwave3dv3.5a.adf
/
lw1.lha
/
arexx_examples
/
lwm
/
ParametricCurve.lwm
< prev
next >
Wrap
Text File
|
1993-08-11
|
5KB
|
215 lines
/* CMD: Parametric Curve
* Create curve object with user-specified parametric functions
* By Arnie Cachelin © 1993 NewTek Inc.
* Tue Jun 22 01:34:00 1993
*/
NUMERIC DIGITS 6
call addlib "LWModelerARexx.port", 0
signal on error
signal on syntax
call addlib "rexxsupport.library", 0, -30, 0
MATHLIB="rexxmathlib.library"
IF POS(MATHLIB , SHOW('L')) = 0 THEN
IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
call notify(1,"!Can't find "MATHLIB)
exit
END
sysnam = 'Parametric Curve'
filnam = 'ENV:PCurve.state'
version = 'Parametric Curve v1.0'
Time=50
Steps=50
typ=1
fil=''
/* Default functions */
FofT.0 = "10*cos(360*t/tmax)"
FofT.1 = "10*sin(360*t/tmax)" /* 1hz sine wave */
FofT.2 = "t" /* random fluctuation 10% */
if (exists(filnam)) then do
if (~open(state, filnam, 'R')) then break
if (readln(state) ~= version) then break
parse value readln(state) with Time Steps typ .
do i=0 to 2
FofT.i = readln(state)
end i
call close state
end
DO FOREVER
call req_begin sysnam
id_mes = req_addcontrol("Make Curve using", 'T', "custom equations X(t), Y(t), Z(t)")
id_Time = req_addcontrol("Time (tmax) ", 'n',0)
id_steps = req_addcontrol("# of steps", 'n')
id_ch.0 = req_addcontrol(" X(t) = ", 'S',40)
id_ch.1 = req_addcontrol(" Y(t) = ", 'S',40)
id_ch.2 = req_addcontrol(" Z(t) = ", 'S',40)
id_typ = req_addcontrol("Create: ",'CH',"Curve Polygon Tube Clones")
id_act = req_addcontrol("",'CH',"Use Load Save")
id_nam = req_addcontrol("Parameter File: ",'T',fil)
call req_setval id_Time, Time
call req_setval id_steps, Steps
call req_setval id_typ, typ
call req_setval id_act, 1
do i=0 to 2
say i FofT.i
call req_setval id_ch.i, FofT.i
end i
if (~req_post()) then do
call req_end
exit
end
act = req_getval(id_act)
typ = req_getval(id_typ)
Time = req_getval(id_Time) % 1
steps = req_getval(id_steps)
do i=0 to 2
FofT.i = req_getval(id_ch.i)
end i
say act
if act=2 then do
fil=getfilename("Load File",fil)
if fil~='(none)' then do
if (~open(state, fil, 'R')) then break
parse value readln(state) with Time Steps .
do i=0 to 2
FofT.i = readln(state)
end i
call close state
call req_setval id_Time, Time
call req_setval id_steps, Steps
call req_setval id_act, 1
do i=0 to 2
say i FofT.i
call req_setval id_ch.i, FofT.i
end i
end
end /* If act=2 */
if act=3 then do
fil=getfilename("Save File",fil)
if fil~='(none)' then do
if (~open(state, fil, 'W')) then break
call writeln state, Time Steps
do i=0 to 2
call writeln state, FofT.i
end i
call close state
call req_setval id_act, 1
end
end
call req_end
if act~=1 then iterate
tmax=Time
if (open(state, filnam, 'W')) then do
call writeln state, version
call writeln state, Time Steps typ
do i=0 to 2
call writeln state, FofT.i
end i
call close state
end
CURV=""
dt=Time/Steps
if typ=4 then do
call Center()
call cut()
end
call meter_begin Steps+2, 'Generating Curve'
call add_begin
do t=0 to Time by dt
interpret 'X='||FofT.0
interpret 'Y='||FofT.1
interpret 'Z='||FofT.2
CURV=CURV||add_point(X Y Z)||' '
call meter_step
end
/* say curv */
call Add_Curve(CURV)
call add_end
call meter_end
if typ=1 then exit
if typ=2 then do
call FreezeCurves()
exit
end
if typ=3 then do
clay=curlayer()
lay=word(emptylayers(),1)
if lay~="" then do
call setlayer(lay)
call setblayer(clay)
call req_begin "Tube Size"
SidId = req_addcontrol("Sides",'N')
RadId = req_addcontrol("Radius",'N',0)
call req_setval SidId, 8,8
call req_setval RadId, 1,1
if ~req_post() then do
call end_all()
exit
end
sides= req_getval(SidId)
r=req_getval(RadId)
call req_end()
t=0
interpret 'X0='||FofT.0
interpret 'Y0='||FofT.1
interpret 'Z0='||FofT.2
t=dt
interpret 'X1='||FofT.0
interpret 'Y1='||FofT.1
interpret 'Z1='||FofT.2
dx=X1-X0
dy=Y1-Y0
dz=Z1-Z0
if dx>dy & dx>dz then ax='X'
else if dz>dy then ax='Z'
else ax='Y'
interpret 'c='ax'0'
call makedisc(r,c,c,ax,sides,0,X0 Y0 Z0)
call railextrude(0)
end
end
if typ=4 then do
clay=curlayer()
lay=word(emptylayers(),1)
if lay~="" then do
call setlayer(lay)
call paste()
t=0
interpret 'X0='||FofT.0
interpret 'Y0='||FofT.1
interpret 'Z0='||FofT.2
call setblayer(clay)
call Move(X0 Y0 Z0)
call railclone(steps)
end
end
exit
call end_all
END /* Forever */
exit
syntax:
error:
call end_all
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit
Center: Procedure
box=boundingbox() /* Should check out empty list ... */
parse var box n x1 x2 y1 y2 z1 z2
cx=-(x2-x1)/2
cy=-(y2-y1)/2
cz=-(z2-z1)/2
call MOVE(cx cy cz)
return box